home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Demo 1.2 Source / Prepare ƒ / MSG Prepare.c next >
Text File  |  1993-11-07  |  2KB  |  90 lines

  1. /**********************************************************************\
  2.  
  3. File:        MSG Prepare.c
  4.  
  5. Purpose:    This module handles storing the resource fork and map
  6.             length to the application space of the resource fork of
  7.             a file (to be checked when that file is run as a
  8.             minimal integrity check).
  9.  
  10.  
  11. MSG Prepare 1.0 -- minimal integrity check preparation program
  12. Copyright (C) 1993 Mark Pilgrim
  13.  
  14. This program is free software; you can redistribute it and/or modify
  15. it under the terms of the GNU General Public License as published by
  16. the Free Software Foundation; either version 2 of the License, or
  17. (at your option) any later version.
  18.  
  19. This program is distributed in the hope that it will be useful,
  20. but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22. GNU General Public License for more details.
  23.  
  24. You should have received a copy of the GNU General Public License
  25. along with this program in a file named "GNU General Public License".
  26. If not, write to the Free Software Foundation, 675 Mass Ave,
  27. Cambridge, MA 02139, USA.
  28.  
  29. \**********************************************************************/
  30.  
  31. #include "MSG Prepare.h"
  32.  
  33. Boolean            gDone;
  34.  
  35. void CheckDropKick(void)
  36. {
  37.     int            i,j,k;
  38.     AppFile        myFile;
  39.     
  40.     CountAppFiles(&i, &j);
  41.     if ((j>0) && (i==0))
  42.     {
  43.         k=1;
  44.         while (k<=j)
  45.         {
  46.             GetAppFiles(k, &myFile);
  47.             OpenFile(myFile.fName, myFile.vRefNum);
  48.             ClrAppFiles(k++);
  49.         }
  50.         gDone=TRUE;
  51.     }
  52. }
  53.  
  54. void OpenFile(Str255 fName, int vRefNum)
  55. {
  56.     int                thisFile;
  57.     long            count;
  58.     long            resMapOffset;
  59.     int                resAttributes;
  60.     long            resDataLength;
  61.     long            resMapLength;
  62.     
  63.     OpenRF(fName, vRefNum, &thisFile);
  64.     count=4L;
  65.     SetFPos(thisFile, 1, 4L);
  66.     FSRead(thisFile, &count, (Ptr)(&resMapOffset));
  67.     resMapOffset+=22L;
  68.     count=2L;
  69.     SetFPos(thisFile, 1, resMapOffset);
  70.     FSRead(thisFile, &count, (Ptr)(&resAttributes));
  71.     resAttributes|=0x8000;
  72.     count=2L;
  73.     SetFPos(thisFile, 1, resMapOffset);
  74.     FSWrite(thisFile, &count, (Ptr)(&resAttributes));
  75.     SetFPos(thisFile, 1, 8L);
  76.     count=4L;
  77.     FSRead(thisFile, &count, (Ptr)(&resDataLength));
  78.     SetFPos(thisFile, 1, 12L);
  79.     count=4L;
  80.     FSRead(thisFile, &count, (Ptr)(&resMapLength)); 
  81.     SetFPos(thisFile, 1, 144L);
  82.     count=4L;
  83.     FSWrite(thisFile, &count, (Ptr)(&resDataLength));
  84.     SetFPos(thisFile, 1, 148L);
  85.     count=4L;
  86.     FSWrite(thisFile, &count, (Ptr)(&resMapLength));
  87.     FSClose(thisFile);
  88.     FlushVol(0L, vRefNum);
  89. }
  90.